package com.kaisademo.zhxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kaisademo.zhxy.mapper.ClazzMapper;
import com.kaisademo.zhxy.pojo.Clazz;
import com.kaisademo.zhxy.service.ClazzService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService {
    @Override
    public IPage<Clazz> getClazzsByOpr(Page<Clazz> clazzPage, Clazz clazz) {
        LambdaQueryWrapper<Clazz> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(clazz.getGradeName() != null){
            lambdaQueryWrapper.eq(Clazz::getGradeName,clazz.getGradeName());
        }
        if(clazz.getName() != null){
            lambdaQueryWrapper.like(Clazz::getName,clazz.getName());
        }
        lambdaQueryWrapper.orderByDesc(Clazz::getId);
        Page<Clazz> selectPage = baseMapper.selectPage(clazzPage, lambdaQueryWrapper);
        return selectPage;
    }
}
